//------------Sonic CD Horz Platform Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 44: TYPE_HORZPLATFORM


sub ObjectMain
	Object.Value5=Oscillation
	Object.Value5<<=1
	if Object.PropertyValue==1
		Object.Value5+=256
	endif
	Cos(Object.Value4,Object.Value5)
	Object.Value4*=6144
	Object.Value4+=Object.XPos
	Object.Value4&=-65536
	Object.Value4-=Object.Value3
	if Object.Value0==1
		if Object.Value1<16
			Object.Value1++
			TempValue0=Object.Value1
			TempValue0&=3
			if TempValue0==3
				Object.Value2=65536
			else
				Object.Value2=0
			endif
		else
			Object.Value2=0
		endif
	else
		if Object.Value1>0
			Object.Value1--
			TempValue0=Object.Value1
			TempValue0&=3
			if TempValue0==3
				Object.Value2=-65536
			else
				Object.Value2=0
			endif
		else
			Object.Value2=0
		endif
	endif
	Object.Value0=0
endsub


sub ObjectPlayerInteraction
	TempValue0=Object.XPos
	Object.XPos=Object.Value3
	PlayerObjectCollision(C_PLATFORM,-32,-9,32,12)
	if CheckResult==1
		Object.Value0=1
		Player.XPos+=Object.Value4
		Player.YPos+=Object.Value2
	endif
	Object.XPos=TempValue0
endsub


sub ObjectDraw
	Cos(Object.Value3,Object.Value5)
	Object.Value3*=6144
	Object.Value3+=Object.XPos
	Object.Value3&=-65536
	Object.YPos+=Object.Value2
	DrawSpriteXY(0,Object.Value3,Object.YPos)
endsub


sub ObjectStartup
	LoadSpriteSheet("R1/Objects.gif")
	SpriteFrame(-32,-16,64,32,101,109)
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
